using System;
using Extensions.FPMath;
using Unity.Entities;
using UnityEngine.Serialization;

namespace Game.Core
{
    [Serializable]
    public unsafe struct DefensePropertyData
    {
        // 生命值
        public float CurHealthPoint;
        public float MaxHealthPoint;
        public float HealthRecover;
        
        // 物理抗性
        public float Armor;
        public float Block;
        public float Dodge;
        public float Resilience;
        
        // 法术抗性
        public float Resistance;
        
        public static DefensePropertyData operator +(DefensePropertyData a) => a;

        public static DefensePropertyData operator -(DefensePropertyData a) =>
            new DefensePropertyData()
            {
                CurHealthPoint = -a.CurHealthPoint,
                MaxHealthPoint = -a.MaxHealthPoint,
                HealthRecover = -a.HealthRecover,
                
                Armor = -a.Armor,
                Block = -a.Block,
                Dodge = -a.Dodge,
                Resilience = -a.Resilience,
                
                Resistance = -a.Resistance,
            };

        public DefensePropertyData Add(DefensePropertyData* p)
        {
            DefensePropertyData r = new DefensePropertyData();
            r.CurHealthPoint = CurHealthPoint + p->CurHealthPoint;
            r.MaxHealthPoint = MaxHealthPoint + p->MaxHealthPoint;
            r.HealthRecover = HealthRecover + p->HealthRecover;
            
            r.Armor = Armor + p->Armor;
            r.Block = Block + p->Block;
            r.Dodge = Dodge + p->Dodge;
            r.Resilience = Resilience + p->Resilience;
            
            r.Resistance = Resistance + p->Resistance;
            return r;
        }
        public static DefensePropertyData operator +(DefensePropertyData a, DefensePropertyData* b) => a.Add(b);
        public static DefensePropertyData operator +(DefensePropertyData a, DefensePropertyData b) => a.Add(&b);
        public DefensePropertyData Subtract(DefensePropertyData* p) => this + -(*p); 
        public static DefensePropertyData operator -(DefensePropertyData a, DefensePropertyData b) => a + (-b);
    }
}